// app.js
const baseUtils = require('./pages/utils/base.utils')
const modelUtils = require('./pages/utils/model.utils')
const constUtils = require('./pages/utils/const.utils')
const cryptoUtils = require('./pages/utils/crypto.utils')
const storageUtils = require('./pages/utils/storage.utils')
const requestUtils = require('./pages/utils/request.utils')
const navigatorUtils = require('./pages/utils/navigator.utils')

App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })

    wx.$base = baseUtils;
    wx.$model = modelUtils;
    wx.$const = constUtils;
    wx.$crypto = cryptoUtils;
    wx.$storage = storageUtils;
    wx.$request = requestUtils;
    wx.$navigator = navigatorUtils;
  },
  globalData: {
    userInfo: null
  }
})
